<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="主题" prop="theme">
        <el-input
          v-model="queryParams.theme"
          placeholder="请输入主题"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系人姓名" prop="telName">
        <el-input
          v-model="queryParams.telName"
          placeholder="请输入联系人姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择客户状态" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="联系方式" prop="howContact">
        <el-input
          v-model="queryParams.howContact"
          placeholder="请输入联系方式"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系日期" prop="contactDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.contactDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择联系日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="下次回访日期" prop="nextRevisist">
        <el-date-picker clearable size="small"
          v-model="queryParams.nextRevisist"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择下次回访日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="负责人" prop="staffFollower">
        <el-input
          v-model="queryParams.staffFollower"
          placeholder="请输入负责人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="跟进记录" prop="followRecord">
        <el-input
          v-model="queryParams.followRecord"
          placeholder="请输入跟进记录"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['crm:record:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['crm:record:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['crm:record:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['crm:record:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主题" align="center" prop="theme" />
            <el-table-column label="联系人姓名" align="center" prop="telName" >
                          <template slot-scope="scope">
                            <el-button
                              size="mini"
                              type="text"
                              @click="getContactInfo(scope.row)"
                              v-hasPermi="['system:record:list']"
                            >{{scope.row.telName}}</el-button>
                          </template>
            </el-table-column>
            <el-table-column label="客户名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        @click="getCustomerInfo1(scope.row)"
                        v-hasPermi="['system:record:list']"
                      >{{scope.row.customerName}}</el-button>
                    </template>
            </el-table-column>
      <el-table-column label="客户状态" align="center" prop="status" />
      <el-table-column label="联系方式" align="center" prop="howContact" />
      <el-table-column label="联系日期" align="center" prop="contactDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.contactDate, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下次回访日期" align="center" prop="nextRevisist" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.nextRevisist, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="负责人" align="center" prop="staffFollower" />
      <el-table-column label="跟进记录" align="center" prop="followRecord" />
      <el-table-column label="最新修改时间" align="center" prop="updateTime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['crm:record:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['crm:record:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog :title="title" :visible.sync="contactDialog" width="800px" append-to-body>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="联系人" name="conFirst">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="联系人详情" name="con1">
              <el-form ref="ContactByTelName" :model="ContactByTelName" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人编号
                          </template>
                          {{ContactByTelName.telNo}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人姓名
                          </template>
                          {{ContactByTelName.telName}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人称谓
                          </template>
                          {{ContactByTelName.conSex}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                客户名称
                          </template>
                          {{ContactByTelName.customerName}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人手机
                          </template>
                          {{ContactByTelName.telephone}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人职务
                          </template>
                          {{ContactByTelName.position}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                销售负责人
                          </template>
                          {{ContactByTelName.staffFollower}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                办公电话
                          </template>
                          {{ContactByTelName.officePhone}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                Email
                          </template>
                          {{ContactByTelName.conEmail}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                修改时间
                          </template>
                          {{ContactByTelName.updateTime}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="地址信息" name="con2">
              <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                          <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                  <el-descriptions-item >
                                    <template slot="label">
                                          国家
                                    </template>
                                    {{CustomerInfo.country}}
                                  </el-descriptions-item>
                                  <el-descriptions-item >
                                    <template slot="label">
                                          省份
                                    </template>
                                    {{CustomerInfo.province}}
                                  </el-descriptions-item>
                                  <el-descriptions-item >
                                    <template slot="label">
                                          城市
                                    </template>
                                    {{CustomerInfo.city}}
                                  </el-descriptions-item>
                                  <el-descriptions-item >
                                    <template slot="label">
                                          区域
                                    </template>
                                    {{CustomerInfo.region}}
                                  </el-descriptions-item>
                                  <el-descriptions-item >
                                    <template slot="label">
                                          联系人地址
                                    </template>
                                    {{ContactByTelName.conAddress}}
                                  </el-descriptions-item>
                          </el-descriptions>
              </el-form>
            </el-collapse-item>
            </el-collapse>
        </el-tab-pane>
          <el-tab-pane label="跟进记录" name="conSecond">
          <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                    <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                      <el-table-column label="主题" align="center" prop="theme"/>
                      <el-table-column label="客户名称" align="center" prop="customerName" />
                      <el-table-column label="联系人姓名" align="center" prop="telName" />
                      <el-table-column label="客户状态" align="center" prop="status" />
                      <el-table-column label="联系方式" align="center" prop="howContact" />
                      <el-table-column label="联系日期" align="center" prop="contactDate" />
                      <el-table-column label="负责人" align="center" prop="staffFollower" />
                      <el-table-column label="跟进记录" align="center" prop="followRecord" />
                      <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                    </el-table>
                  </el-form>
          </el-tab-pane>
    </el-tabs>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="submitForm2">确 定</el-button>
           <el-button @click="cancel2">取 消</el-button>
         </div>
      </el-dialog>

    <el-dialog :title="title" :visible.sync="dialogVisible" width="800px" append-to-body>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="客户详情" name="first">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="基本信息" name="1">
           <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
              <el-descriptions-item >
                <template slot="label">
                      客户名称
                </template>
                {{CustomerInfo.customerName}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      上级单位
                </template>
                {{CustomerInfo.superior}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      客户编号
                </template>
                {{CustomerInfo.customerNo}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      客户状态
                 </template>
                 {{CustomerInfo.customerStatus}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      客户类型
                 </template>
                 {{CustomerInfo.customerType}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      销售负责人
                 </template>
                 {{CustomerInfo.staffFollower}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      重要级别
                 </template>
                 {{CustomerInfo.level}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      最新服务时间
                 </template>
                 {{CustomerInfo.contactDateLast}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      最新分配人
                 </template>
                 {{CustomerInfo.followLast}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      是否新客户
                </template>
                {{CustomerInfo.isNewCu}}
              </el-descriptions-item>
            </el-descriptions>
           </el-form>
           </el-collapse-item>

            <el-collapse-item title="工商信息" name="2">
            <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
              <el-descriptions class="margin-top"  :column="2" :size="size" border>
                    <el-descriptions-item >
                      <template slot="label">
                            纳税人识别号
                      </template>
                      {{CustomerInfo.taxpayerNo}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            注册时间
                      </template>
                      {{CustomerInfo.registerDate}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            公司性质
                      </template>
                      {{CustomerInfo.companyNature}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            客户规模
                      </template>
                      {{CustomerInfo.customerSize}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            法定代表人
                      </template>
                      {{CustomerInfo.legalRepresent}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            注册资金
                      </template>
                      {{CustomerInfo.registerAc}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            所属行业
                      </template>
                      {{CustomerInfo.industry}}
                    </el-descriptions-item>
                    <el-descriptions-item >
                      <template slot="label">
                            经营范围
                      </template>
                      {{CustomerInfo.businessScope}}
                    </el-descriptions-item>
              </el-descriptions>
           </el-form>
            </el-collapse-item>

            <el-collapse-item title="动态信息" name="3">
              <el-form ref="customerList" :model="customerList" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                下次回访日期
                          </template>
                            {{CustomerInfo.nextRevisitTime}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                未联系天数
                          </template>
                          177
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                最新联系日期
                          </template>
                          {{CustomerInfo.contactDateLast}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                最新进展
                          </template>
                          {{CustomerInfo.lastProgress}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                创建时间
                          </template>
                          {{CustomerInfo.createTime}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                修改时间
                          </template>
                          {{updateTime}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="首要联系人" name="4">
              <el-form ref="FirstContactInfo" :model="FirstContactInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人姓名
                          </template>
                          {{FirstContactInfo.telName}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人职务
                          </template>
                          {{FirstContactInfo.position}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人称谓
                          </template>
                          {{FirstContactInfo.conSex}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                办公电话
                          </template>
                          {{FirstContactInfo.officePhone}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人手机
                          </template>
                          {{FirstContactInfo.telephone}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人住址
                          </template>
                          {{FirstContactInfo.conAddress}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                联系人Email
                          </template>
                          {{FirstContactInfo.conEmail}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="地址信息" name="5">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        国家
                                  </template>
                                  {{CustomerInfo.country}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        省份
                                  </template>
                                  {{CustomerInfo.province}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        城市
                                  </template>
                                  {{CustomerInfo.city}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        区域
                                  </template>
                                  {{CustomerInfo.region}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                  <template slot="label">
                                        详细地址
                                  </template>
                                  {{CustomerInfo.address}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                    </el-collapse-item>

                        <el-collapse-item title="备注信息" name="6">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        备注
                                  </template>
                                  {{CustomerInfo.markInfo}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

                     <el-collapse-item title="附件信息" name="7">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        附件信息
                                  </template>
                                  {{CustomerInfo.enclosureInfo}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

                     <el-collapse-item title="服务合同信息" name="8">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        合同服务信息
                                  </template>
                                  {{CustomerInfo.serviceContractInfo}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

                     <el-collapse-item title="评论信息" name="9">
                      <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                        <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                <el-descriptions-item >
                                  <template slot="label">
                                        评论信息
                                  </template>
                                  {{CustomerInfo.comment}}
                                </el-descriptions-item>
                        </el-descriptions>
                      </el-form>
                     </el-collapse-item>

           </el-collapse>
          </el-tab-pane>

          <el-tab-pane label="联系人" name="10">
            <el-form ref="Contact" :model="Contact" :rules="rules" label-width="100px">
              <el-table :data="Contact" @selection-change="handleSelectionChange" empty-text="暂无数据">
                <el-table-column label="联系人姓名" align="center" prop="telName"/>
                <el-table-column label="联系人编号" align="center" prop="telNo" />
                <el-table-column label="职务" align="center" prop="position" />
                <el-table-column label="手机" align="center" prop="telephone" />
                <el-table-column label="销售负责人" align="center" prop="staffFollower" />
                <el-table-column label="修改时间" align="center" prop="updateTime" />
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleUpdate(scope.row)"
                      v-hasPermi="['system:customer:edit']"
                    >修改</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="handleDelete(scope.row)"
                      v-hasPermi="['system:customer:remove']"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-tab-pane>

          <el-tab-pane label="跟进记录" name="11">
          <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                    <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                      <el-table-column label="主题" align="center" prop="theme"/>
                      <el-table-column label="客户名称" align="center" prop="customerName" />
                      <el-table-column label="联系人姓名" align="center" prop="telName" />
                      <el-table-column label="客户状态" align="center" prop="status" />
                      <el-table-column label="联系方式" align="center" prop="howContact" />
                      <el-table-column label="联系日期" align="center" prop="contactDate" />
                      <el-table-column label="负责人" align="center" prop="staffFollower" />
                      <el-table-column label="跟进记录" align="center" prop="followRecord" />
                      <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                    </el-table>
                  </el-form>
          </el-tab-pane>
    </el-tabs>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="submitForm1">确 定</el-button>
           <el-button @click="cancel1">取 消</el-button>
         </div>
      </el-dialog>


    <!-- 添加或修改跟进记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="主题" prop="theme">
          <el-input v-model="form.theme" placeholder="请输入主题" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="联系人姓名" prop="telName">
          <el-input v-model="form.telName" placeholder="请输入联系人姓名" />
        </el-form-item>
        <el-form-item label="客户状态">
          <el-radio-group v-model="form.status">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="联系方式" prop="howContact">
          <el-input v-model="form.howContact" placeholder="请输入联系方式" />
        </el-form-item>
        <el-form-item label="联系日期" prop="contactDate">
          <el-date-picker clearable size="small"
            v-model="form.contactDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择联系日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="下次回访日期" prop="nextRevisist">
          <el-date-picker clearable size="small"
            v-model="form.nextRevisist"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择下次回访日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="负责人" prop="staffFollower">
          <el-input v-model="form.staffFollower" placeholder="请输入负责人" />
        </el-form-item>
        <el-form-item label="跟进记录" prop="followRecord">
          <el-input v-model="form.followRecord" placeholder="请输入跟进记录" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRecord, getRecord, delRecord, addRecord, updateRecord ,getCustomerInfo,getFollowRecord,getContact,getContactByTelName,getFirstContactInfoByCustomerName} from "@/api/crm/followrecord";

export default {
  name: "Record",
  data() {
    return {
      activeNames: ['1'],
      activeName: 'second',
      Contact: [],
      ContactObj: {},
      CustomerInfo: {},
      FollowRecord: [],
      FirstContactInfo: {},
      dialogVisible: false,
      contactDialog: false,
      size: '',
      uncontactDays: '',
      updateTime: '',
      data: {},
      ContactByTelName: {},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 跟进记录表格数据
      recordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        theme: null,
        customerName: null,
        telName: null,
        status: null,
        howContact: null,
        contactDate: null,
        nextRevisist: null,
        staffFollower: null,
        followRecord: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询跟进记录列表 */
    getList() {
      this.loading = true;
      listRecord(this.queryParams).then(response => {
        this.recordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
cancel1() {
              this.dialogVisible = false;
              this.FollowRecord=[];
              this.Contact=[];
              this.reset();
            },
                        cancel2() {
                          this.contactDialog = false;
                          this.FollowRecord=[];
                          this.reset();
                        },
                                    submitForm1() {
                                      this.dialogVisible = false;
                                      this.FollowRecord=[];
                                      this.Contact=[];
                                      this.reset();
                                    },
                                                submitForm2() {
                                                  this.contactDialog = false;
                                                  this.FollowRecord=[];
                                                  this.reset();
                                                },
    getContactInfo(row){
    const telName = row.telName;
                        const customerName = row.customerName;

                        this.updateTime= row.updateTime;
                        this.uncontactDays=row.uncontactDays;
              getContactByTelName(telName).then(response => {
                   this.ContactByTelName=response.data;
                   console.log(this.ContactByTelName)
                   this.contactDialog=true;
                   this.size='50';
              })
                    getCustomerInfo(customerName).then(response => {
                        this.CustomerInfo=response.data;
                        console.log(this.CustomerInfo);
                        this.size='50';
                    })
                         getFollowRecord(customerName).then(response => {
                                             let list=response.data;
                                             this.FollowRecord.push(...response.data);
                                             this.size='50';
                         })
    },
                handleChange(val) {
                              },
         handleClick(tab, event) {
              },
getCustomerInfo1(row){
      const customerName = row.customerName;
      const telName=row.telName;
      this.updateTime= row.updateTime;
      this.uncontactDays=row.uncontactDays;
      getCustomerInfo(customerName).then(response => {
          this.CustomerInfo=response.data;
          this.dialogVisible=true;
          this.title= "客户信息";
          this.size='50';
      })
      getFollowRecord(customerName).then(response => {
                          let list=response.data;
                          this.FollowRecord.push(...response.data);
                          this.dialogVisible=true;
                          this.size='50';
      })
      getContact(customerName).then(response => {
                          this.ContactObj=response.data;
                          let list =response.data;
                          console.log(response.data)
                          this.Contact.push(...response.data);
                          this.dialogVisible=true;
                          this.size='50';
      })
      getFirstContactInfoByCustomerName(customerName).then(response => {
          this.FirstContactInfo=response.data;
                          this.dialogVisible=true;
                          this.size='50';
      })
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        theme: null,
        customerName: null,
        telName: null,
        status: "0",
        howContact: null,
        contactDate: null,
        nextRevisist: null,
        staffFollower: null,
        followRecord: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加跟进记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRecord(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改跟进记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRecord(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRecord(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除跟进记录编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delRecord(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('crm/record/export', {
        ...this.queryParams
      }, `crm_record.xlsx`)
    }
  }
};
</script>
